/**
 * Copyright (C) 2017-2018 pinganfang, Inc. All Rights Reserved.
 */
package com.pingan.haofang.searchcloud.web.test.tutorials;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.BeanUtils;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * @author huhailiang937
 * @date 2017年6月3日下午4:43:21
 * @since 1.0.0
 */
public class HdmpHouse {

    private Integer id;
    private Integer cityId;
    private Integer areaId;
    private String name;
    private String address;
    private Integer price;
    private String location_coordinate;
    private List<Integer> belongUserIds;
    private List<String> belongUserNames;
    private String modifyDate;
    private int timestamp;
    private long maxVersion;
    public static String str = "东部蔚蓝海岸领地花公告称，收入和毛利的强劲增长主要由于本报告期内医药自营业务及医药电商平台业务快速成长所致。公告显示，医药自营业务收入达16亿元，同比增长100.2%。医药自营业务的年度活跃消费者超过1800万。报告期内，天猫医药馆商品交易总额(GMV)超过人民币250亿元，同比增长超过50%。天猫医药馆的年度活跃消费者已超过1亿。";

    public static <E> E build(Integer id, Class<E> clazz) {
        HdmpHouse house = new HdmpHouse();
        house.setId(id);
        house.setName("绿城万科皇家" + id + "号");
        int strid=(id+str.length()) % str.length();
        house.setAddress(str.substring(0,strid));
        house.setAreaId(id % 12 + 1);
        house.setCityId(id % 4 + 1);
        house.setPrice((id % 10 + 1) * 1000);
        house.setLocation_coordinate("3" + (id % 8 + 1) + ".850609,11" + (id % 7 + 1) + ".476141");
        house.setBelongUserIds(Arrays.asList(id, id + 1, id + 4, id + 9));
        house.setBelongUserNames(Arrays.asList("张" + id, "张" + (id + 1), "张" + (id + 4), "张" + (id + 9)));

        int daysPlus = new Random().nextInt(20) % (20 - (-20) + 1) + -20;
        Date randomDate = DateUtils.addDays(new Date(), daysPlus);
        house.setModifyDate(DateFormatUtils.format(randomDate, "yyyy-MM-dd'T'HH:mm:ss"));
        house.setTimestamp((int) (randomDate.getTime() / 1000));
        house.setMaxVersion(System.currentTimeMillis());

        E e = null;
        try {
            e = clazz.newInstance();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        BeanUtils.copyProperties(house, e);
        return e;
    }

    /**
     * @return the id
     */
    public Integer getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * @return the cityId
     */
    public Integer getCityId() {
        return cityId;
    }

    /**
     * @param cityId the cityId to set
     */
    public void setCityId(Integer cityId) {
        this.cityId = cityId;
    }

    /**
     * @return the areaId
     */
    public Integer getAreaId() {
        return areaId;
    }

    /**
     * @param areaId the areaId to set
     */
    public void setAreaId(Integer areaId) {
        this.areaId = areaId;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @return the price
     */
    public Integer getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(Integer price) {
        this.price = price;
    }

    /**
     * @return the location_coordinate
     */
    public String getLocation_coordinate() {
        return location_coordinate;
    }

    /**
     * @param location_coordinate the location_coordinate to set
     */
    public void setLocation_coordinate(String location_coordinate) {
        this.location_coordinate = location_coordinate;
    }

    /**
     * @return the belongUserIds
     */
    public List<Integer> getBelongUserIds() {
        return belongUserIds;
    }

    /**
     * @param belongUserIds the belongUserIds to set
     */
    public void setBelongUserIds(List<Integer> belongUserIds) {
        this.belongUserIds = belongUserIds;
    }

    /**
     * @return the belongUserNames
     */
    public List<String> getBelongUserNames() {
        return belongUserNames;
    }

    /**
     * @param belongUserNames the belongUserNames to set
     */
    public void setBelongUserNames(List<String> belongUserNames) {
        this.belongUserNames = belongUserNames;
    }

    public String getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(String modifyDate) {
        this.modifyDate = modifyDate;
    }

    public int getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(int timestamp) {
        this.timestamp = timestamp;
    }

    public long getMaxVersion() {
        return maxVersion;
    }

    public void setMaxVersion(long maxVersion) {
        this.maxVersion = maxVersion;
    }
}
